package Service;

import DAL.SqlHelper;
import Entity.News;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class NewsService {
    public void AddNews(){}
    public void DeleteNews(){}
    public void UpdateNews(){}
    public List<News> QueryNews() throws SQLException {
        String sql="Select * from news";
        ResultSet rs= SqlHelper.executeQuery(sql);
        List<News> lsNews=new ArrayList<News>();
        while (rs.next())
        {
            News news=new News();
            news.setIdnews(rs.getInt(1));
            news.setCategory(rs.getString(2));
            news.setTitle(rs.getString(3));
            news.setContent(rs.getString(4));
            news.setAuthor(rs.getString(5));
            news.setNewsdate(rs.getDate(6));
            lsNews.add(news);
        }
        return lsNews;
    }
    public void GetNews(){}
}
